package leetcode.editor.cn;

import java.util.Arrays;
import java.util.HashSet;

/**
题目名字---:存在重复元素
题目编号---:217	
解题时间---:2021-10-16 11:20:19
*/

public class ContainsDuplicate{
    public static void main(String[] args) {
        Solution solution = new ContainsDuplicate().new Solution();    
    }
    public boolean containsDuplicate(int[] nums) {
        HashSet<Integer> hashSet = new HashSet<>();
        for (int i = 0; i < nums.length; i++) {
            hashSet.add(nums[i]);
        }
        return hashSet.size()!=nums.length;
    }
//leetcode submit region begin(Prohibit modification and deletion)
class Solution {
    public boolean containsDuplicate(int[] nums) {
        return nums.length != Arrays.stream(nums).distinct().count();
    }
}
//leetcode submit region end(Prohibit modification and deletion)


}